import { EventManager } from "../Managers/EventManager";
import { IProxy } from "../Interfaces/IProxy";
import { Client } from "../Network/Socket/Client";
import { ClientManager } from "../Managers/ClientManager";
import FScene from "./FScene";
import { ClientName } from "../Enums/ClientName";

export class FProxy implements IProxy {
    public static ClassName:string = "FProxy";
    protected client: Client = null;
    protected scene: FScene = null;
    protected isNeedDisposeClient: boolean = true;
    public initialize(): void {
        this.initEvents();
        this.client = this.initClient();
        this.initHandlers();
    }

    protected initClient(): Client {
        return ClientManager.GetClientByName(ClientName.GAME_CLIENT);
    }

    protected initEvents(): void {

    }
    protected initHandlers(): void {

    }
    protected removeEvents(): void {
        EventManager.removeEvent(this);
    }
    public dispose(): void {
        this.removeEvents();
        if (this.isNeedDisposeClient && this.client != null)
            ClientManager.DisposeClients(this.client.clientName);
    }
}


